package net.dview.freefoote.speakmessageservice;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;

public class WidgetReciever extends AppWidgetProvider
{
	public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
	{
		// Loop over my widgets.
		for (int i = 0; i < appWidgetIds.length; i++)
		{
			int appWidgetId = appWidgetIds[i];

			// Get the remote view.
			RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.stop_widget_layout);

			Intent intentData = new Intent(context, SpeakService.class);
			intentData.putExtra("stopNow", true);
			PendingIntent pendStopIntent = PendingIntent.getService(context, 0, intentData, 0);
			
			views.setOnClickPendingIntent(R.id.widget_stop_now_button, pendStopIntent);

			// Update the current widget.
			appWidgetManager.updateAppWidget(appWidgetId, views);
		}
	}
}